package com.xxq.semester.service.impl.chat;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxq.semester.entity.chat.ChatMessages;
import com.xxq.semester.mapper.ChatMessagesMapper;
import com.xxq.semester.service.chat.IChatMessagesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author saki
 * @since 2025-07-13
 */
@Service
public class ChatMessagesServiceImpl extends ServiceImpl<ChatMessagesMapper, ChatMessages> implements IChatMessagesService {
    @Override
    public List<ChatMessages> getByChatId(Integer id){
        QueryWrapper<ChatMessages> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("chat_id",id);
        return baseMapper.selectList(queryWrapper);
    }
    @Override
    public boolean deleteByChatId(Integer id){
        QueryWrapper<ChatMessages> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("chat_id",id);
        return baseMapper.delete(queryWrapper)>0;
    }
    @Override
    public boolean addChatMessage(ChatMessages chatMessages){
        return baseMapper.insert(chatMessages)>0;
    }
}
